<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      label-width="68px"
    >
      <div class="shuxing">
        <el-form-item label="行政区划" prop="">
          <treeselect
            class="shuxing1"
            v-model="queryParams.enterArea"
            :options="deptOptions"
            :normalizer="normalizer"
            placeholder="选择区域"
          />
        </el-form-item>
      </div>
      <el-form-item label="备案主体" prop="">
        <el-input
          v-model="queryParams.enterName"
          placeholder="请输入备案主体"
        />
      </el-form-item>

      <el-form-item label="组织形式" prop="mainCertificeType">
        <el-select
          v-model="queryParams.orgId"
          placeholder="请选择组织形式"
          clearable
          size="small"
        >
          <el-option label="企业/个体工商户" value="企业/个体工商户" />
          <el-option label="合作社" value="合作社" />
          <el-option label="家庭农场" value="家庭农场" />
          <el-option label="个人" value="个人" />
          <el-option label="其他" value="其他" />
        </el-select>
      </el-form-item>
      <el-form-item label="主体属性" prop="mainCertificeType">
        <el-select
          v-model="queryParams.sysProId"
          placeholder="请选择主体属性"
          clearable
          size="small"
        >
          <el-option label="一般主体" value="一般主体" />
          <el-option label="屠宰场" value="屠宰场" />
          <el-option label="生鲜乳企业" value="生鲜乳企业" />
          <el-option label="加工企业" value="加工企业" />
          <el-option label="其他" value="其他" />
        </el-select>
      </el-form-item>

      <el-form-item label="备案时间" prop="sysProId">
        <div class="block">
          <el-date-picker
            v-model="queryParams.recordTime"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </div>
      </el-form-item>
      <el-form-item label="认证类型" prop="mainCertificeType">
        <el-select
          v-model="queryParams.mainCertificeType"
          multiple
          placeholder="请选择"
        >
          <el-option
            v-for="item in options1"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['enterpriseInfo:EnterpriseInfo:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['enterpriseInfo:EnterpriseInfo:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['enterpriseInfo:EnterpriseInfo:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['enterpriseInfo:EnterpriseInfo:export']"
          >导出</el-button
        >
      </el-col>
    </el-row>

    <el-table
      v-loading="loading"
      :data="EnterpriseInfoList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column
        label="序号"
        align="center"
        type="index"
        :index="indexMethod"
        width="80"
      />
      <el-table-column type="selection" width="50" align="center" />
      <el-table-column label="备案主体" align="center" prop="enterName" />
      <el-table-column
        label="社会信用代码"
        align="center"
        prop="socialCreditCode"
      />
      <el-table-column label="地址" align="center" prop="enterAddress" />
      <el-table-column label="法定代表人" align="center" prop="legalName" />
      <el-table-column label="备案机构" align="center" prop="recordName" />
      <el-table-column label="备案时间" align="center" prop="recordTime" />

      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['enterpriseInfo:EnterpriseInfo:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleSelect(scope.row)"
            v-hasPermi="['enterpriseInfo:EnterpriseInfo:edit']"
            >详情</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['enterpriseInfo:EnterpriseInfo:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改种植主体管理对话框 -->
    <el-dialog
      :visible.sync="open"
      width="60%"
      append-to-body
      class="add"
      custom-class="str1"
    >
      <div class="add-top">{{ title }}</div>
      <div class="add-box">
        <!-- 主体信息 -->
        <el-divider content-position="left" class="add-title"
          ><span class="h1">主体信息</span>
          <span class="h3">
            (温馨提示:附件单张照片不能超过5MB，单个视频不能超过50M)
          </span></el-divider
        >
        <el-form
          ref="form"
          :model="form"
          :rules="rules"
          label-width="100px"
          :disabled="disabled"
        >
          <div class="add-from">
            <el-form-item label="行政区划" prop="">
              <treeselect
                class="shuxing1"
                v-model="form.tPlantEnterpriseInfo.enterArea"
                :options="deptOptions"
                :normalizer="normalizer"
                placeholder="选择区域"
              />
            </el-form-item>

            <el-form-item label="备案主体" prop="phone">
              <el-input
                v-model="form.tPlantEnterpriseInfo.enterName"
                placeholder="请输入备案主体"
              />
            </el-form-item>

            <el-form-item label="主体类型">
              <el-select
                v-model="form.tPlantEnterpriseInfo.plantId"
                placeholder="请选择主体类型"
              >
                <el-option label="农资店" value="农资店" />
                <el-option label="兽药店" value="兽药店" />
                <el-option label="种植业主体" value="种植业主体" />
                <el-option label="畜牧业主体" value="畜牧业主体" />
                <el-option label="渔业主体" value="渔业主体" />
                <el-option label="其他主体" value="其他主体" />
              </el-select>
            </el-form-item>
            <el-form-item label="主体属性">
              <el-select
                v-model="form.tPlantEnterpriseInfo.sysProId"
                placeholder="请选择主体属性"
              >
                <el-option label="一般主体" value="一般主体" />
                <el-option label="屠宰场" value="屠宰场" />
                <el-option label="生鲜乳企业" value="生鲜乳企业" />
                <el-option label="加工企业" value="加工企业" />
                <el-option label="其他" value="其他" />
              </el-select>
            </el-form-item>
            <el-form-item label="组织形式">
              <el-select
                v-model="form.tPlantEnterpriseInfo.orgId"
                placeholder="请选择组织形式"
              >
                <el-option label="企业/个体工商户" value="企业/个体工商户" />
                <el-option label="合作社" value="合作社" />
                <el-option label="家庭农场" value="家庭农场" />
                <el-option label="个人" value="个人" />
                <el-option label="其他" value="其他" />
              </el-select>
            </el-form-item>
            <el-form-item label="主体证件类型" prop="">
              <el-input
                v-model="form.tPlantEnterpriseInfo.mainCertificeType"
                placeholder="请输入主体证件类型"
              />
            </el-form-item>

            <el-form-item label="地址" prop="">
              <el-input
                v-model="form.tPlantEnterpriseInfo.enterAddress"
                placeholder="请输入地址"
              />
            </el-form-item>
            <el-form-item label="社会信用代码" prop="">
              <el-input
                v-model="form.tPlantEnterpriseInfo.socialCreditCode"
                placeholder="请输入社会信用代码"
              />
            </el-form-item>
            <el-form-item label="生产经营类型">
              <el-select
                v-model="form.tPlantEnterpriseInfo.productOperationType"
                placeholder="请选择生产经营类型"
              >
                <el-option label="生产型主体" value="生产型主体" />
                <el-option label="经营型主体" value="经营型主体" />
                <el-option label="生产经营型主体" value="生产经营型主体" />
                <el-option label="主体" value="主体" />
              </el-select>
            </el-form-item>
            <el-form-item label="经度" prop="longitude">
              <el-input
                v-model="form.tPlantEnterpriseInfo.longitude"
                placeholder="请输入经度"
              />
            </el-form-item>
            <el-form-item label="维度" prop="dimension">
              <el-input
                v-model="form.tPlantEnterpriseInfo.dimension"
                placeholder="请输入维度"
              />
            </el-form-item>
            <el-form-item label="行业">
              <el-select
                v-model="form.tPlantEnterpriseInfo.industry"
                multiple
                placeholder="请选择"
              >
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>

            <el-form-item label="主体身份码" prop="">
              <el-input
                v-model="form.tPlantEnterpriseInfo.enterIdcard"
                placeholder="请输入主体身份证"
              />
            </el-form-item>
            <el-form-item label="" prop=""> </el-form-item>
            <el-form-item label="企业图片" prop="qualityImg">
              <div class="updateimg">
                <el-upload
                  :action="MixinUploadAllApi"
                  :on-success="uploadSuccess"
                  :on-remove="delGiftImg"
                  :file-list="fileListqiye"
                  :multiple="false"
                  :limit="1"
                  :before-upload="beforeImgUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    &nbsp;建议上传jpg/png文件，尺寸（宽*高）750*327
                  </div>
                </el-upload>
                <img :src="photoqiye" />
              </div>
            </el-form-item>
            <el-form-item label="主体证件照片" prop="qualityImg">
              <div class="updateimg">
                <el-upload
                  :action="MixinUploadAllApi"
                  :on-success="uploadSuccess1"
                  :on-remove="delGiftImg1"
                  :file-list="fileListzhuti"
                  :multiple="false"
                  :limit="1"
                  :before-upload="beforeImgUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    &nbsp;建议上传jpg/png文件，尺寸（宽*高）750*327
                  </div>
                </el-upload>
                <img :src="photozhuti" />
              </div>
            </el-form-item>

            <!-- 法定代表人信息· -->
            <el-divider content-position="left" class="add-title"
              ><span class="h1">发行代表人信息</span>
            </el-divider>
            <el-form-item label="法定代表人" prop="">
              <el-input
                v-model="form.tCorporateLegaPersonInfo.legalName"
                placeholder="请输入法定代表人"
              />
            </el-form-item>
            <el-form-item label="法人电话" prop="phone">
              <el-input
                v-model="form.tCorporateLegaPersonInfo.legalPhone"
                placeholder="请输入法人电话"
              />
            </el-form-item>
            <el-form-item label="公民身份号码" prop="">
              <el-input
                v-model="form.tCorporateLegaPersonInfo.legalIdcard"
                placeholder="请输入公民身份号码"
              />
            </el-form-item>
            <el-form-item label="固定电话号码" prop="">
              <el-input
                v-model="form.tCorporateLegaPersonInfo.legalMobile"
                placeholder="请输入固定电话号码"
              />
            </el-form-item>

            <!--身份证正面 idcardPositiveImg -->
            <el-form-item label="法人身份证正面照" prop="qualityImg">
              <div class="updateimg">
                <el-upload
                  :action="MixinUploadAllApi"
                  :on-success="uploadSuccess2"
                  :on-remove="delGiftImg2"
                  :file-list="fileListfaren"
                  :multiple="false"
                  :limit="1"
                  :before-upload="beforeImgUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    &nbsp;建议上传jpg/png文件，尺寸（宽*高）750*327
                  </div>
                </el-upload>
                <img :src="photofaren" />
              </div>
            </el-form-item>

            <!--身份证反面 idcardNopositiveImg -->
            <el-form-item label="法人身份证反面照" prop="qualityImg">
              <div class="updateimg">
                <el-upload
                  :action="MixinUploadAllApi"
                  :on-success="uploadSuccess3"
                  :on-remove="delGiftImg3"
                  :file-list="fileListfarenfan"
                  :multiple="false"
                  :limit="1"
                  :before-upload="beforeImgUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    &nbsp;建议上传jpg/png文件，尺寸（宽*高）750*327
                  </div>
                </el-upload>
                <img :src="photofarenfan" />
              </div>
            </el-form-item>

            <!--手持身份证 idcardHanderImg -->
            <el-form-item label="法人手持身份证照" prop="qualityImg">
              <div class="updateimg">
                <el-upload
                  :action="MixinUploadAllApi"
                  :on-success="uploadSuccess4"
                  :on-remove="delGiftImg4"
                  :file-list="fileListfarenhand"
                  :multiple="false"
                  :limit="1"
                  :before-upload="beforeImgUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    &nbsp;建议上传jpg/png文件，尺寸（宽*高）750*327
                  </div>
                </el-upload>
                <img :src="photofarenhand" />
              </div>
            </el-form-item>

            <el-form-item label="" prop=""> </el-form-item>
            <!-- 联系人信息 -->
            <el-divider content-position="left" class="add-title"
              ><span class="h1">联系人信息</span>
            </el-divider>
            <el-form-item label="联系人姓名" prop="">
              <el-input v-model="form.tEnterContactsInfo.contactsName" />
            </el-form-item>
            <el-form-item label="联系人电话">
              <el-input
                v-model="form.tEnterContactsInfo.contactsPhone"
                maxlength="11"
              />
            </el-form-item>
            <el-form-item label="联系人邮箱" prop="email">
              <el-input
                v-model="form.tEnterContactsInfo.contactsMail"
                maxlength="50"
              />
            </el-form-item>
            <el-form-item label="固定电话号码" prop="">
              <el-input v-model="form.tEnterContactsInfo.contactsMobile" />
            </el-form-item>
            <el-form-item label="传真号码" prop="">
              <el-input v-model="form.tEnterContactsInfo.contactsFax" />
            </el-form-item>
            <el-form-item label="" prop=""> </el-form-item>

            <!-- 备案信息 -->

            <el-divider content-position="left" class="add-title"
              ><span class="h1">备案信息</span>
            </el-divider>

            <el-form-item label="备案机构" prop="">
              <el-input v-model="form.tRecordInfo.recordName" />
            </el-form-item>
            <el-form-item label="备案时间" prop="">
              <div class="block">
                <el-date-picker
                  v-model="form.tRecordInfo.recordTime"
                  type="date"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </div>
            </el-form-item>
          </div>

          <!-- 主体介绍信息 -->
          <el-divider content-position="left" class="add-title"
            ><span class="h1">主体介绍信息</span>
          </el-divider>
          <div class="zhu">
            <el-form-item label="主体介绍">
              <el-input
                type="textarea"
                v-model="form.tSubjectIntroduce.subjectIntroduce"
                rows="6"
                class="zhu-textare"
              ></el-input>
            </el-form-item>
            <el-form-item label="主体介绍照片" prop="qualityImg">
              <div class="updateimg1">
                <el-upload
                  :action="MixinUploadAllApi"
                  :on-success="uploadSuccess51"
                  :on-remove="delGiftImg51"
                  :file-list="fileListzhutijieshao"
                  :multiple="false"
                  :limit="5"
                  :before-upload="beforeImgUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    &nbsp;建议上传jpg/png文件，尺寸（宽*高）750*327
                  </div>
                </el-upload>
              
              </div>
              <div class="zhutiphoto">
                  <img v-for="(item,index) in photozhutijieshao" :src="item" :key="index" />
                </div>
            </el-form-item>
          </div>
          <!-- 主体介绍视频 -->
          <el-divider content-position="left" class="add-title"
            ><span class="h1">主体介绍视频</span>
          </el-divider>
          <div class="zhu">
            <el-form-item label="主体介绍视频" prop="qualityImg">
              <div class="updateimg1" >
                <el-upload
                  :action="MixinUploadAllApi"
                  :on-success="uploadSuccess61"
                  :on-remove="delGiftImg61"
                  :file-list="fileListshipinjieshao"
                  :multiple="false"
                  :limit="3"
                  :before-upload="beforeImgUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    &nbsp;建议上传jpg/png文件，尺寸（宽*高）750*327
                  </div>
                </el-upload>
                  
              </div>
               <div class="zhutiphoto">
                <img v-for="(item,index) in photoshipinjieshao" :src="item" :key="index" />
                 </div>
            </el-form-item>
          
          </div>
        </el-form>
        <div class="footer-fixed">
          <div slot="footer" class="dialog-footer foot-ri">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {
  listEnterpriseInfo,
  getEnterpriseInfo,
  delEnterpriseInfo,
  addEnterpriseInfo,
  updateEnterpriseInfo,
  exportEnterpriseInfo,
  getTree,
} from "@/api/enterpriseInfo/EnterpriseInfo";

export default {
  name: "EnterpriseInfo",
  data() {
    return {
      zhuti:"",
      shipin:"",
      // 上传地址
      imgaction: "http://www.baudi.com",
      // 是否上传
      autoUpload: false,
      // 上传图片
      fileListqiye: [],
      photoqiye: [],
      // 主体证件照片
      fileListzhuti: [],
      photozhuti: "",
      //  法人正照
      fileListfaren: [],
      photofaren: "",
      //  法人反照
      fileListfarenfan: [],
      photofarenfan: "",
      //  法人手持
      fileListfarenhand: [],
      photofarenhand: "",
      //  主体介绍
      listzhu:[],
      fileListzhutijieshao: [],
      photozhutijieshao: [],
      
      //  主体介绍
      listpin:[],
      fileListshipinjieshao: [],
      photoshipinjieshao: [],
    
      MixinUploadAllApi: process.env.VUE_APP_BASE_API + "/file/upload",

      //表单的使用
      disabled: false,

      // s树状图
      deptOptions: [],
      //
      options1: [
        {
          value: "无公害产品",
          label: "无公害产品",
        },
        {
          value: "绿色食品",
          label: "绿色食品",
        },
        {
          value: "有机农产品",
          label: "有机农产品",
        },
        {
          value: "地理标志农产品",
          label: "地理标志农产品",
        },
        {
          value: "名特优新农产品",
          label: "名特优新农产品",
        },
        {
          value: "GAP认证农产品",
          label: "GAP认证农产品",
        },
      ],
      // 行业
      options: [
        {
          value: "畜牧业",
          label: "畜牧业",
        },
        {
          value: "种植业",
          label: "种植业",
        },
        {
          value: "渔业",
          label: "渔业",
        },
        {
          value: "其他",
          label: "其他",
        },
      ],
      value3: [],

      // 时间选择器
      value1: "",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 种植主体管理表格数据
      EnterpriseInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        enterName: undefined,
        enterArea: undefined,
        plantId: undefined,
        orgId: undefined,
        sysProId: undefined,
        mainCertificeType: undefined,
        enterAddress: undefined,
        socialCreditCode: undefined,
        productOperationType: undefined,
        longitude: undefined,
        dimension: undefined,
        industry: undefined,
        enterIdcard: undefined,
        enterImg: undefined,
        enterLicenseImg: undefined,
        createDate: undefined,
      },
      // 表单参数
      form: {
        // 主体信息双向绑定
        tPlantEnterpriseInfo: {},
        // 法人双向绑定
        tCorporateLegaPersonInfo: {},
        // 联系人信息
        tEnterContactsInfo: {},
        // 备案信息
        tRecordInfo: {},
        // 主体介绍信息
        tSubjectIntroduce: {},
      },
      // 表单校验
      rules: {
        email: [
          {
            type: "email",
            message: "'请输入正确的邮箱地址",
            trigger: ["blur", "change"],
          },
        ],
        phone: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: ["blur", "change"],
          },
        ],
      },
    };
  },
  components: { Treeselect },
  created() {
    this.getList();
    this.getTree();
  },
  methods: {
    // 序号
    indexMethod(index) {
      return index + 1;
    },
    // 图片上传
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    // 行政区划分列表
    getTree() {
      this.loading = true;
      getTree().then((response) => {
        this.deptOptions = this.handleTree(response.data, "id");
      });
    },

    /** 查询种植主体管理列表 */
    getList() {
      this.loading = true;
      listEnterpriseInfo(this.queryParams).then((response) => {
        this.EnterpriseInfoList = response.rows;
        console.log(response);
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      // 主体信息双向绑定
      (this.form.tPlantEnterpriseInfo = {}),
        // 法人双向绑定
        (this.form.tCorporateLegaPersonInfo = {}),
        // 联系人信息
        (this.form.tEnterContactsInfo = {}),
        // 备案信息
        (this.form.tRecordInfo = {}),
        // 主体介绍信息
        (this.form.tSubjectIntroduce = {});
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.value1 = "";
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.photos();
      this.disabled = false;
      this.reset();
      this.open = true;
      this.title = "添加种植主体管理";
    },
    // 上传图片初始化
    photos(){
          // 上传图片
      this.fileListqiye= []; 
      this.photoqiye= [];
      // 主体证件照片
      this.fileListzhuti= [];
      this.photozhuti= "";
      //  法人正照
      this.fileListfaren=[];
      this.photofaren="";
      //  法人反照
      this.fileListfarenfan=[];
      this.photofarenfan="";
      //  法人手持
      this.fileListfarenhand= [];
      this.photofarenhand="";
      //  主体介绍
      this.listzhu=[];
      this.fileListzhutijieshao= [];
      
      this.photozhutijieshao= [];
     
      //  主体介绍
     this.listpin=[];
     this.fileListshipinjieshao= [];
     this.photoshipinjieshao= [];
   

     
    },
    // 图片的渲染
    xuanphoto(res){
      // 主体
      this.photoqiye = res.tPlantEnterpriseInfo.enterImg;
      this.photozhuti = res.tPlantEnterpriseInfo.enterLicenseImg;
      // 法人
      this.photofaren = res.tCorporateLegaPersonInfo.idcardPositiveImg;
      this.photofarenfan=res.tCorporateLegaPersonInfo.idcardNopositiveImg;
      this.photofarenhand =res.tCorporateLegaPersonInfo.idcardHanderImg;
      this.photozhutijieshao=res.tSubjectIntroduce.subjectIntroduceImg.split(",");
      this.photoshipinjieshao= res.tSubjectIntroduce.subjectIntroduceVideo.split(",");
      console.log("this.listzhu",this.photozhutijieshao);
      console.log("this.listpin",this.photoshipinjieshao);
     
      
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.photos();
      this.zhuti=1;
      this.shipin=1;
      this.disabled = false;
      this.reset();
      const id = row.id || this.ids;
      getEnterpriseInfo(id).then((response) => {
        response.data.tPlantEnterpriseInfo.industry = response.data.tPlantEnterpriseInfo.industry.split(
          ","
        );
        this.form = response.data;
        this.open = true;
        this.title = "修改种植主体管理";
        this.xuanphoto(response.data)
      });
    },

    /** 详情按钮操作 */
    handleSelect(row) {
      this.disabled = true;
      this.reset();
      const id = row.id || this.ids;
      getEnterpriseInfo(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "种植主体详情页";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.form.tPlantEnterpriseInfo.industry = this.form.tPlantEnterpriseInfo.industry.toString();
      let time1 = new Date(this.form.tRecordInfo.recordTime);
      let otimeYear = time1.getFullYear();
      let otimeMou = time1.getMonth() + 1;
      let otimeDay = time1.getDate();
      let otime2 = otimeYear + "-" + otimeMou + "-" + otimeDay;
      this.form.tRecordInfo.recordTime = otime2;
      console.log("this.fileListzhutijieshao",this.photozhutijieshao)
      console.log("this.subjectIntroduceVideo",this.photoshipinjieshao)
      this.form.tSubjectIntroduce.subjectIntroduceImg=this.photozhutijieshao.toString();
      this.form.tSubjectIntroduce.subjectIntroduceVideo=this.photoshipinjieshao.toString();
      console.log("this.form",this.form);
      this.$refs["form"].validate((valid) => {
        if (valid) {
          addEnterpriseInfo(this.form).then((response) => {
            if (response.code == 0) {
              this.msgSuccess("操作成功");
              this.open = false;
              this.getList();
            }
          });
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认删除种植主体管理编号为"' + ids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delEnterpriseInfo(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(function () {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有种植主体管理数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportEnterpriseInfo(queryParams);
        })
        .then((response) => {
          this.download(response.data);
        })
        .catch(function () {});
    },
    /** 转换部门数据结构 */
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.id,
        label: node.label,
        children: node.children,
      };
    },
    // 图片上传
    // 图片上传时
    submitUpload() {
      this.$refs.upload.submit();
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    // 主体
    uploadSuccess(res) {
      this.photoqiye = res.url;
      this.$set(this.form.tPlantEnterpriseInfo, "enterImg", res.url);
      this.$refs["form.tPlantEnterpriseInfo"].validateField("enterImg");
    },
    /** 图片移除之后 */
    delGiftImg() {
      this.fileListqiye = [];
      this.form.avatar = "";
      this.photoqiye = "";
      this.$refs["form.tPlantEnterpriseInfo"].validateField("enterImg");
    },

    // 企业
    uploadSuccess1(res) {
      console.log(res);
      this.photozhuti = res.url;
      this.$set(this.form.tPlantEnterpriseInfo, "enterLicenseImg", res.url);
      this.$refs["form.tPlantEnterpriseInfo"].validateField("enterLicenseImg");
      
    },
    /** 图片移除之后 */
    delGiftImg1() {
      this.fileListzhuti = [];
      this.form.avatar = "";
      this.photozhuti = "";
      this.$refs["form.tPlantEnterpriseInfo"].validateField("enterLicenseImg");
    },

    // 法人正
    uploadSuccess2(res) {
      this.photofaren = res.url;
      this.$set(this.form.tCorporateLegaPersonInfo, "idcardPositiveImg", res.url);
      this.$refs["form.tCorporateLegaPersonInfo"].validateField("idcardPositiveImg");
    },
    /** 图片移除之后 */
    delGiftImg2() {
      this.fileListfaren = [];
      this.form.avatar = "";
      this.photofaren = "";
      this.$refs["form.tCorporateLegaPersonInfo"].validateField("idcardPositiveImg");
    },
    // 法人反
    uploadSuccess3(res) {
      this.photofarenfan = res.url;
      this.$set(this.form.tCorporateLegaPersonInfo, "idcardNopositiveImg", res.url);
      this.$refs["form.tCorporateLegaPersonInfo"].validateField("idcardNopositiveImg");
    },
    /** 图片移除之后 */
    delGiftImg3() {
      this.fileListfarenfan = [];
      this.form.avatar = "";
      this.photofarenfan = "";
      this.$refs["form.tCorporateLegaPersonInfo"].validateField("idcardNopositiveImg");
    },

    // 法人手持身份证
    uploadSuccess4(res) {
      this.photofarenhand = res.url;
      this.$set(this.form.tCorporateLegaPersonInfo, "idcardHanderImg", res.url);
      this.$refs["form.tCorporateLegaPersonInfo"].validateField("idcardHanderImg");
    },
    /** 图片移除之后 */
    delGiftImg4() {
      this.fileListfarenfan = [];
      this.form.avatar = "";
      this.photofarenhand = "";
      this.$refs["form.tCorporateLegaPersonInfo"].validateField("idcardHanderImg");
    },

    // 主体介绍图片
    uploadSuccess51(res) {
      if(this.zhuti==1)
      {
        this.photozhutijieshao=[];
        this.zhuti=2;
      }
      if(this.fileListzhutijieshao==null)
      {

      this.photozhutijieshao[0]=res.url;
      }
      else{
         this.photozhutijieshao.push(res.url);
      }
      this.$set(this.form, "idcardHanderImg", res.url);
      this.$refs["form"].validateField("idcardHanderImg");
    },
    /** 图片移除之后 */
    delGiftImg51() {
      this.fileListzhutijieshao = [];
      this.form.avatar = "";
      this.photozhutijieshao = [];
      this.$refs["form"].validateField("idcardHanderImg");
    },


    // 主体介绍视频
    uploadSuccess61(res) {
         if(this.shipin==1)
      {
        this.photoshipinjieshao=[];
        this.shipin=2;
      }
       if(this.photoshipinjieshao==null)
      {

      this.photoshipinjieshao[0]=res.url;
      }
      else{
         this.photoshipinjieshao.push(res.url);
      }

      this.$set(this.form, "subjectIntroduceVideo", res.url);
      this.$refs["form"].validateField("subjectIntroduceVideo");
    },
    delGiftImg61() {
      this.fileListshipinjieshao = [];
      this.form.avatar = "";
      this.photoshipinjieshao = [];
      this.$refs["form"].validateField("subjectIntroduceVideo");
    },


    /** 图片上传之前的校验  */
    beforeImgUpload(file) {
      const isLt1M = file.size / 5120 / 5120 < 1;
      if (!isLt1M) {
        this.msgWarning("上传图片大小不能超过 5MB!");
      }
      var FileExt = file.name.replace(/.+\./, "");
      if (["jpg", "jpeg", "png"].indexOf(FileExt.toLowerCase()) === -1) {
        this.msgWarning("请上传后缀名为jpg/jpeg/png的图片附件！");
        return false;
      }
      return isLt1M;
    },
  },
};
</script>
<style lang="scss" scoped>
.shuxing {
  width: 250px;
  float: left;
  .shuxing1 {
    width: 150px !important;
    height: 35px;
  }
}
.footer-fixed {
  width: 100%;
  height: 30px;
  background-color: white;
  // position: absolute;
  position: sticky;
  bottom: -25px;
  right: 40px;
}
.add-top {
  width: 100%;
  height: 40px;
  line-height: 40px;
  font-size: 25px;
  background-color: white;
  // border-bottom: 2px solid #999;
  position: sticky;
  top: 0;
  z-index: 999;
}
.footer-fixed .foot-ri {
  float: right;
  // width: 30%;
}
.el-dialog__header {
  position: absolute;
  top: 0;
}
.add {
  // overflow: hidden;
  box-sizing: border-box;
  // position: relative;
}
.add-from {
  width: 100%;
  display: flex;
  position: relative;
  flex-wrap: wrap;
  box-sizing: border-box;
  justify-content: space-around;
}
.add-from .el-form-item {
  width: 40%;
  padding: 0 20px;
}
.add-title {
  padding: 5px 0;
  .h1 {
    float: left;
    font-size: 20px;
  }
  .h3 {
    color: red;
    float: left;
    font-size: 14px;
    margin-left: 10px;
    line-height: 25px;
  }
}
.upload-img {
  width: 40%;
}
.el-select,
.el-select--medium {
  width: 100%;
}
// 主体介绍部分
.zhu {
  width: 100%;
  .img-list {
    width: 100%;
    display: flex;
    justify-content: left;
    flex-wrap: wrap;
    ul {
      width: 100%;
    }
  }
}
.otime .el-date-editor--daterange {
  width: 100% !important;
}
.zhu .add-from .el-form-item {
  width: 70%;

  padding: 0 20px;
}

.updateimg {
  width: 20%;
  max-width: 500px;
  min-width: 200px;
  float: left;
}
.updateimg img {
  width: 150px;
  height: 150px;
}
.zhutiphoto {
  width: 100%;
  float: left;
  img{
    width: 150px;
    height: 150px;
    float: left;
  }
}
.updateimg1 {
  width: 100%;
  max-width: 500px;
  min-width: 200px;
  float: left;
}
</style>